#!/bin/sh
# Copyright (C) 2024-2025 KoudaiPC Computer Technologies Co., Ltd.
# script name: huangdi-setup-environment.sh
# author: david921518@qq.com

# 1. setup WAN interface
uci set network.wan=interface
uci set network.wan.device=eth0
uci set network.wan.proto=dhcp
uci commit

# 2. setup device bridge br-lan ports
uci delete network.@device[0].ports
uci add_list network.@device[0].ports=dummy0
uci commit

# 3. restart network service
service network restart

# 4. install kmod-dummy
apk update
apk install kmod-dummy
service network restart

# 5. install toosl for enlarging partition size
#sed "s#downloads.openwrt.org#mirrors.aliyun.com/openwrt#g" -i /etc/apk/distfeeds.conf
apk install parted
apk install losetup
apk install lsblk
apk install resize2fs

# 6. enlarge partition
export loop_device=$(losetup -f)
losetup $loop_device /dev/sda
echo -e "Fix" | parted ---pretend-input-tty "$loop_device" print
parted "$loop_device" resizepart 2 100%
parted "$loop_device" print

# 7. restart system
#poweroff

